package apply.apply4;

import apply.data.MyAnnotation;
import apply.data.Person;
import org.junit.Test;

import java.lang.reflect.Field;

public class GetAnnotationTest {
    // @MyAnnotation("t_persons")
    @Test
    public void test1() {
        Class<Person> personClass = Person.class;
        MyAnnotation declaredAnnotation = personClass.getDeclaredAnnotation(MyAnnotation.class);
        System.out.println(declaredAnnotation.value());

    }

    //     @MyAnnotation("info")
    //    private static String info;
    @Test
    public void testFieldAnnotation() throws NoSuchFieldException {
        Class<Person> personClass = Person.class;
        Field info = personClass.getDeclaredField("info");
        info.setAccessible(true);
        MyAnnotation declaredAnnotation = info.getDeclaredAnnotation(MyAnnotation.class);
        System.out.println(declaredAnnotation.value()); // info
    }
}
